'use strict';

var React = require('react');
var ListStore = require('../stores/list');


var BoxComponent = React.createClass({
  getInitialState : function(){
    // 在组件挂载之前调用一次。返回值将会作为 this.state 的初始值。
    return { topHeight :content:'还未输入'};
  },
  hanlderChange : function(){
    this.setState({content:ListStore.getAll()});

  },
  componentDidMount : function(){
    // 注册 store 响应事件
    // ListStore.bind( 'change', this.listChanged );
    ListStore.addChangeListener(this.hanlderChange);

  },
  componentWillUnmount : function(){
    //取消注册store响应事件
    // ListStore.unbind( 'change', this.listChanged );
    ListStore.removeChangeListener(this.hanlderChange);
  },
  render: function() {
    var content = ListStore.getAll();
    return (
      /* jshint ignore:start */
      <div>
        <p>{ this.state.content }</p>
      </div>
      /* jshint ignore:end */
    );
  }
});

module.exports = BoxComponent;